import { defineStore } from 'pinia'
import { getMvUrlApi, getNewMvApi, getTopMvListApi, getVideoListApi, getWyMvApi, getAllMvApi } from '@renderer/api'
import { ref } from 'vue'

export const useVideosStore = defineStore('videosStore', () => {
    const videoList = ref([] as any[])
    const newMvList = ref([] as any[])
    const wyMvList = ref([] as any[])
    const topMvList = ref([] as any[])
    const allMvList = ref([] as any[])
    const mvInfo = ref({} as { url: string, id: number | null })
    // 获取推荐视频列表
    const getVideoList = async () => {
        let res: any = await getVideoListApi()
        videoList.value = res.result
    }
    const getNewMv = async (limit: number) => {
        let res: any = await getNewMvApi(limit)
        newMvList.value = res.data
    }
    const getMvInfo = async (id: number) => {
        let res: any = await getMvUrlApi(id)
        mvInfo.value = res.data
    }
    const getWyMvList = async (limit: number) => {
        let res: any = await getWyMvApi(limit)
        wyMvList.value = res.data
    }
    const getTopMvList = async (params: { limit: number, area: string }) => {
        let res: any = await getTopMvListApi(params)
        topMvList.value = res.data
    }
    const getAllMvList = async (params: { limit: number, order: string, area: string, type: string }) => {
        let res: any = await getAllMvApi(params)
        allMvList.value = res.data
    }

    return {
        videoList,
        newMvList,
        mvInfo,
        wyMvList,
        topMvList,
        allMvList,
        getTopMvList,
        getWyMvList,
        getVideoList,
        getNewMv,
        getMvInfo,
        getAllMvList,
    }
})